<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 参数(...加上变量名)就是剩余参数
        // 1.把传递的参数全部相加
        const fn = (...args) => {
            let num = 0;
            args.forEach((value) => {
                num += value;
            });
            return num;
        }
        console.log(fn(1, 4, 6, 7));;

        // 2.剩余参数与解构配合使用
        let array = [3, 4, 5, 6, 1, 0];
        let [i, ...is] = array;
        console.log(i); //i对应3
        console.log(is); //is对应除了i之外的所有数字，它集结成一个数组
    </script>
</body>

</html>